package edu.fiu.cis.personalize.server.graph;

import java.io.Serializable;

import edu.fiu.cis.personalize.server.graph.store.NodeEdges;

@SuppressWarnings("serial")
public abstract class Node implements Serializable {

	
	protected int id;
	protected double rank;
	protected NodeEdges edges;
	protected String stringKey;
	
	private boolean isNew = false;
	
	public boolean isNew() {
		return isNew;
	}
	
	public void setNew(boolean isNew) {
		this.isNew = isNew;
	}

	public Node(int id,String strKey) {
		super();
		this.id = id;
		this.stringKey = strKey;
		setRank(1);
		edges = new NodeEdges(id);
	}

	public void setRank(double rank) {
		this.rank = rank;
	}

	public double getRank() {
		return rank;
	}

	public int getId() {
		return id;
	}

	public abstract NodeType getType();
	
	public String getStringKey(){
		return stringKey;
	}

	public void setEdgeTo(Node node, double weight) {
		edges.setOutLink(node, weight);
	}

	public void setEdgeFrom(Node node, double weight) {
		edges.setInLink(node, weight);
	}

	public int getInDegree(NodeType type) {
		return edges.getInDegree(type);
	}

	public int getOutDegree(NodeType type) {
		return edges.getOutDegree(type); 
	}
	
	public boolean hasEdgeTo(int id,NodeType type){
		return edges.getEdgeMap(type).hasOutLink(id);
	}

	public NodeEdges getEdges() {
		return edges;
	}
}